/*
 * Vec2D.h
 *
 *  Created on: Jan 1, 2011
 *      Author: burek
 */

#ifndef VEC2D_H_
#define VEC2D_H_

struct Vec2D
{
    float X, Y;

    inline Vec2D( void ) {}
    inline Vec2D( const float x, const float y )
    { X = x; Y = y; }

    inline Vec2D operator = ( const Vec2D& A )
    { X = A.X; Y = A.Y; return *this; }

    inline bool operator == ( const Vec2D& A ) const
    { return X == A.X && Y == A.Y; }

    inline Vec2D operator + ( const Vec2D& A ) const
    { return Vec2D( X + A.X, Y + A.Y ); }

    inline Vec2D operator - ( const Vec2D& A ) const
    { return Vec2D( X - A.X, Y - A.Y ); }

    inline Vec2D operator + ( const float A ) const
    { return Vec2D( X + A, Y + A ); }

    inline Vec2D operator * ( const float A ) const
    { return Vec2D( X * A, Y * A ); }

    inline Vec2D operator / ( const float A ) const
    { return Vec2D( X / A, Y / A ); }

    inline float Dot( const Vec2D& A ) const
    { return A.X*X + A.Y*Y; }

    inline float Length( void ) const
    { return sqrt(X * X + Y * Y); }

    inline Vec2D Normalize(void) const
    {
    	float len = Length();
    	return Vec2D(X / len, Y / len);
    }

    inline void operator += ( const Vec2D& A )
    { X += A.X; Y += A.Y; }

    inline void operator -= ( const Vec2D& A )
    { X -= A.X; Y -= A.Y; }

    inline void operator *= ( const float A )
    { X *= A; Y *= A; }
};

#endif /* VEC2D_H_ */
